#!/bin/bash

# Author: Marius Scurtescu
#         http://marius.scurtescu.com
#
# Copyright: (c) Marius Scurtescu
# License: GNU GPL (http://www.gnu.org/copyleft/gpl.html)
#
# Dependencies: Nautilus, xclip
#
# Install:
#  - copy to ~/.gnome2/nautilus-scripts/
#  - make sure that XCLIP_CMD below points to xclip on your system
#
# Usage:
#  - right click on some files in Nautilus and select Scripts / Copy filename(s)
#  - the absolute file names of the selected files will be copied to the clipboard, one file per line
#
# Version 1.0, November 16, 2005
# first public release
#

XCLIP_CMD=/usr/X11R6/bin/xclip

if [ ! -e $XCLIP_CMD ] ; then
    if [ -z `which $XCLIP_CMD` ] ; then
        zenity --error --text="xclip not found!

Please put xclip on your search path or edit XCLIP_CMD in the script:
$0"
        exit 1
    fi
fi

CLIPBOARD_TEXT=$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS

if [ -z $CLIPBOARD_TEXT ] ; then
    CLIPBOARD_TEXT=`pwd`
fi

echo "$CLIPBOARD_TEXT" | $XCLIP_CMD -select clipboard

